home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13288 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.0 KB

  1. Path: library.erc.clarkson.edu!rpi!not-for-mail
  2. From: Kevin Lew <Kevin.Lew@Adelaide.Edu.Au>
  3. Newsgroups: comp.lang.c++.moderated,comp.lang.c++
  4. Subject: How do I return a function pointer?
  5. Date: 24 Mar 1996 18:32:43 -0000
  6. Organization: The University of Adelaide
  7. Sender: cppmods@netlab.cs.rpi.edu
  8. Approved: Dietmar.Kuehl@uni-konstanz.de
  9. Message-ID: <4j44gb$j3n@netlab.cs.rpi.edu>
  10. Reply-To: Kevin.Lew@Adelaide.Edu.Au
  11. NNTP-Posting-Host: netlab.cs.rpi.edu
  12. X-Original-Date: Sun, 24 Mar 1996 18:10:46 +1030
  13.  
  14. {The following is just a duplicate of an article I just rejected with
  15. an corresponding comment. Note that articles posted to a moderated
  16. newsgroup do not appear immediately, as they need a moderator to
  17. approve it. Also, after this is done, the article as to be distributed
  18. which also takes some time. -mod}
  19.  
  20. POST
  21. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.5 sun4c)
  22. To: kev@cs.adelaide.edu.au
  23.  
  24. Hello there everyone,
  25.  
  26. Thanx for reading me. I have a function which needs to return a pointer
  27. to a function but unfortunately I dont know how the header should be
  28. like. get_fn (see below) takes a char* argument and must return a
  29. pointer to a function taking no arguments and return an int. I tried
  30. both
  31.     (int(*)()) get_fn(char* name) { // code here }
  32. and
  33.     int(*)() get_fn(char* name) { // code here }
  34.  
  35. I also tried
  36.  
  37.     typedef int(*)() fnptr;
  38.  
  39.     fnptr get_fn(char* name) { // code here }
  40.  
  41. but nothing works, any help? Please email me because I don't regularly
  42. read the news.
  43.  
  44. Kevin
  45.  
  46. -- 
  47. Kevin C F Lew                    ,-_|\     email: kev@cs.adelaide.edu.au
  48. Department of Computer Science  /     \             phone: (08) 303 4728
  49. University of Adelaide          \_,-*_/               fax: (08) 303 4366
  50. South Australia 5005                 v       www.cs.adelaide.edu.au/~kev
  51.  
  52.       [ Articles to moderate: mailto:c++-submit@netlab.cs.rpi.edu ]
  53.       [  Read the C++ FAQ: http://www.connobj.com/cpp/cppfaq.htm  ]
  54.       [  Moderation policy: http://www.connobj.com/cpp/guide.htm  ]
  55.       [      Comments? mailto:c++-request@netlab.cs.rpi.edu       ]
  56.